<template>
	<view class="ranking">
		<view class="titles">{{activityInfo.title}}</view>
		<view class="contentBox">
			<view class="rankBox">
				<template v-for="(item,index) in oneRankList">
					<view :class="['items','reds',index == 0 ? 'one' : '']" :key="item.id" @click="toDetial(item)">
						<view class="imgBox">
							<image v-if="index == 0" src="../../static/image/one.png" mode=""></image>
							<image v-if="index == 1" src="../../static/image/two.png" mode=""></image>
							<image v-if="index == 2" src="../../static/image/three.png" mode=""></image>
						</view>
						<view class="hao">{{item.number}}号</view>
						<view class="name">
							{{item.title}}
						</view>
						<view class="numbers">
							{{item.vote_num}}票
						</view>
					</view>
				</template>
				
				<!-- <view class="items one">
					<view class="imgBox">
						<image src="../../static/image/one.png" mode=""></image>
					</view>
					<view class="hao">1号</view>
					<view class="name">
						xx社区
					</view>
					<view class="numbers">
						9999票
					</view>
				</view>
				<view class="items">
					<view class="imgBox">
						<image src="../../static/image/two.png" mode=""></image>
					</view>
					<view class="hao">1号</view>
					<view class="name">
						xx社区
					</view>
					<view class="numbers">
						9999票
					</view>
				</view>
				<view class="items">
					<view class="imgBox">
						<image src="../../static/image/three.png" mode=""></image>
					</view>
					<view class="hao">1号</view>
					<view class="name">
						xx社区
					</view>
					<view class="numbers">
						9999票
					</view>
				</view> -->
			</view>
			<view class="guiZeBox">
				<view class="titleBox">
					<text class="lefts">排名</text>
					<view class="rightBox">
						<text>候选社区</text>
						<text>票数</text>
					</view>
				</view>
				<view class="consList">
					<block v-for="(item,index) in twoRankList" :key="item.id">
						<view :class="['items',index <= 6 ? 'origes' : (index <= 116 ? 'blacks' : '')]"  @click="toDetial(item)">
							<view class="nums">
								<image v-if="index <= 6" src="../../static/image/hot.png" mode=""></image>
								<view class="images" v-else></view>
								<text>{{item.rank_no}}</text>
							</view>
							<view class="names">
								<text>{{item.title}}</text>
								<text>{{item.vote_num}}</text>
							</view>
						</view>
						<u-divider v-if="index == (last_rank - 4)" text="晋级线"></u-divider>
					</block>
				</view>
				<view class="totals">
					共{{totalList.length}}条数据
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {activityDetial,activityRank} from '../../request/api.js'
	export default {
		data() {
			return {
				// 活动id
				activity_id:14,
				// 活动内容
				activityInfo:{},
				oneRankList:[],
				twoRankList:[],
				totalList:[],
				
				last_rank:0,
			};
		},
		methods:{
			// 获取活动详情
			getactivityDetial(){
				let obj = {
					id:this.activity_id
				};
				activityDetial(obj).then(res=>{
					console.log(res);
					let picarr = res.data.picarr.split(',');
					this.activityInfo = res.data;
					this.activityInfo.picarr = picarr;
				})
			},
			// 获取排名数据
			getactivityRank(){
				let obj = {
					activity_id:this.activity_id
				};
				activityRank(obj).then(res=>{
					console.log(res)
					let list = res.data;
					this.oneRankList = list.slice(0, 3);
					this.twoRankList = list.slice(3);
					this.totalList = res.data;
					
					this.last_rank = res.data[0].last_rank;
				})
			},
			// 跳转对应详情
			toDetial(data){
				console.log(data);
				uni.navigateTo({
					url:'/pages/itemDetial/itemDetial?id='+data.id
				})
			},
		},
		onLoad() {
			this.activity_id = uni.getStorageSync('activity_id');
			this.getactivityDetial();
			this.getactivityRank();
		}
	}
</script>

<style lang="less">
.ranking{
	width: 100%;
	min-height: 100vh;
	padding: 83rpx 28rpx 37rpx 28rpx;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	.titles{
		width: 560rpx;
		height: auto;
		font-size: 38rpx;
		color: #1D1D1D;
		line-height: 60rpx;
		margin: 0 auto;
		text-align: center;
		font-weight: bold;
	}
	.contentBox{
		flex: 1;
		padding: 10rpx;
		box-sizing: border-box;
		.rankBox{
			width: 100%;
			height: 282rpx;
			position: relative;
			margin-top: 45rpx;
			.reds{
				color: #b21820 !important;
			}
			.items{
				width: 217rpx;
				height: 226rpx;
				border-radius: 14rpx;
				background-color: #fff;
				position: absolute;
				bottom: 0;
				.imgBox{
					width: 55rpx;
					height: 66rpx;
					margin: 0 auto;
					image{
						width: 100%;
						height: 100%;
					}
				}
				.hao,.name,.numbers{
					font-size: 24rpx;
					// color: #818181;
					text-align: center;
				}
				.name{
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				.hao{
					margin-top: 40rpx;
				}
				&:nth-child(1){
					width: 274rpx;
					height: 282rpx;
					box-shadow: 0 5rpx 30rpx 0 rgba(0, 0, 0, 0.1);
					z-index: 99;
					left: 0;
					right: 0;
					margin: 0 auto;
					button:0;
					.imgBox{
						width: 102rpx;
						height: 98rpx;
						margin: 0 auto;
						image{
							width: 100%;
							height: 100%;
						}
					}
					.hao{
						margin-top: 55rpx;
					}
				}
				&:nth-child(3){
					right: 0;
				}
			}
		}
		.guiZeBox{
			width: 100%;
			height: auto;
			border-radius: 18rpx;
			overflow: hidden;
			margin-top: 41rpx;
			.titleBox{
				width: 100%;
				height: 76rpx;
				background-color: #255EB2;
				line-height: 76rpx;
				color: #fff;
				font-size: 31rpx;
				font-weight: bold;
				padding:0 30rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				// text{
				// 	&:nth-child(2){
				// 		margin-left: 20rpx;
				// 	}
				// }
				.lefts{
					flex: none;
				}
				.rightBox{
					flex: 1;
					display: flex;
					justify-content: space-between;
					margin-left: 15px;
				}
			}
			.consList{
				width: 100%;
				height: auto;
				padding: 0 22rpx;
				box-sizing: border-box;
				background-color: #fff;
				.items{
					width: 100%;
					height: 70rpx;
					// line-height: 70rpx;
					display: flex;
					align-items: center;
					font-size: 24rpx;
					// color: #818181;
					color: #999;
					border-bottom: 1rpx solid #818181;
					box-sizing: border-box;
					&:last-child{
						border: none;
					}
					.nums{
						width: 100rpx;
						flex: none;
						display: flex;
						align-items: center;
						image{
							width: 30rpx;
							height: 30rpx;
							margin-right: 10rpx;
						}
						.images{
							width: 30rpx;
							height: 30rpx;
							margin-right: 10rpx;
						}
					}
					.names{
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-between;
					}
				}
				.reds{
					color: #b21820;
				}
				.blacks{
					color: #333;
				}
				.origes{
					color: #F68915;
				}
			}
			.totals{
				font-size: 24rpx;
				color: #818181;
				margin-left: 20rpx;
				margin-top: 42rpx;
			}
		}
	}
	
}
</style>
